<?php
/**
 * FastApp.
 * 8/18/25
 * @Author deepsea
 * @Contact (telegram:deepsea159)
 */

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateAiTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('ai_knowledge_file', function (Blueprint $table) {
            $table->engine = 'Innodb';
            $table->comment('知识库文件');
            $table->bigIncrements('id')->comment('主键');
            $table->bigInteger('created_by')->unsigned();
            $table->bigInteger('file_id')->unsigned();
            $table->tinyInteger('status')->unsigned()->default(0);
        });
        Schema::create('ai_account_chat', function (Blueprint $table) {
            $table->engine = 'Innodb';
            $table->comment('用户对话记录');
            $table->bigIncrements('id')->comment('主键');
            $table->bigInteger('chat_id')->unsigned();
            $table->char('user_id', 32)->default('')->index();
            $table->char('role', 16)->default('');
            $table->tinyInteger('type')->unsigned()->comment('0文本1文件')->default(0);
            $table->text('content')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('ai_knowledge_file');
        Schema::dropIfExists('ai_account_chat');
    }
}
